 
<template>
    <div class="setting">
        <el-card class="box-card">
            <template #header>
                <div class="card-header">
                    <span>数据汇总</span>
                    <el-select v-model="type" class="m-2" placeholder="Select" style="width: 140px;margin-left: 20px;"
                        @change="changetype">
                        <el-option label="平均分一" :value="0" />
                        <el-option label="平均分二" :value="1" />
                    </el-select>
                    <el-button type="primary" style="float: right;" @click="winopen">导出</el-button>
                </div>
            </template>
            <!-- <div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div> -->


            <el-table v-if="tableData.value?.length > 0" :data="tableData.value" border
                style="width: 100%;height: calc(100vh - 250px);">
                <el-table-column type="index" label="顺序" width="180" />
                <el-table-column prop="number" label="序号" />
                <el-table-column prop="total_fraction_1" label="舞蹈基本功" />
                <el-table-column prop="total_fraction_2" label="即兴表演" />
                <el-table-column prop="total_fraction_3" label="专业知识考察" />
                <el-table-column prop="total_fraction_4" label="剧目展示" />
                <el-table-column label="总分">
                    <template #default="scope">
                        {{ fractionTotal(scope.row) }}
                    </template>
                </el-table-column>
            </el-table>

        </el-card>



    </div>
</template>
    
<script setup lang='ts'>
import { ref, reactive } from "vue"
import { scoreList, summary, edit_rater, del_rater } from "../../api/api"
import { ElMessage } from "element-plus"
let type = ref(0)


let tableData = reactive({ value: [] })

const gettable = () => {
    scoreList({ link_id: '', bool: type.value }).then((res) => {
        tableData.value = res.data
    })
}
gettable()

let dialogVisible = ref(false)
let form = reactive({ name: '' })
let formid = ref(0)
const opendialog = (item?: any) => {
    console.log(item)
    if (item.id) {
        form.name = item.name
        formid.value = item.id
        dialogVisible.value = true
    } else {
        dialogVisible.value = true
    }

}






const winopen = () => {
    summary({ bool: type.value }).then((res: any) => {
        console.log(res)
        const blob = new Blob([res],);
        const linkNode = document.createElement("a");
        linkNode.download = '演出汇总.doc';
        linkNode.style.display = "none";
        linkNode.href = URL.createObjectURL(blob); //生成一个Blob URL
        document.body.appendChild(linkNode);
        linkNode.click(); //模拟在按钮上的一次鼠标单击
        URL.revokeObjectURL(linkNode.href); // 释放URL 对象
        document.body.removeChild(linkNode);
    })
}


const fractionTotal = (row: any) => {


    let model1 = row.total_fraction_1 ? row.total_fraction_1 - 0 : 0
    let model2 = row.total_fraction_2 ? row.total_fraction_2 - 0 : 0
    let model3 = row.total_fraction_3 ? row.total_fraction_3 - 0 : 0
    let model4 = row.total_fraction_4 ? row.total_fraction_4 - 0 : 0
    return (model1*100 + model2*100 + model3*100 + model4*100)/100

}

const changetype = () => {
    gettable()
}

</script>
    
<style lang="less" scoped>
.setting {

    // background: white;
    // padding: 30px;
    .el-card {
        min-height: calc(100vh - 104px);

    }
}
</style>
